//
//  YDOAStockCell.swift
//  YDOAProduct
//
//  Created by 占益民 on 2017/11/22.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOAStockCell: UITableViewCell {

 
    
    @IBOutlet weak var deleteBtn: UIButton!
    @IBOutlet weak var editBtn: UIButton!
    @IBOutlet weak var amountLb: UILabel! //金额
    @IBOutlet weak var priceLb: UILabel! // 价格
    @IBOutlet weak var remainLb: UILabel! // 剩余数量
    @IBOutlet weak var guiGeLb: UILabel! //规格
    @IBOutlet weak var goosNameLb: UILabel! //物品名称
    
    @IBOutlet weak var goodsTypeLb: UILabel! //物品类型
    
    var isApply : Bool? //判断是否是 月度申请界面进来的  其他的是库存管理或办公申请
    var  callback : ((_ index:Int, _ type:Int) -> Swift.Void)? = nil
    var index:Int!
    
    //1  申请界面进入    2 库存界面进入
    var type : Int!{
        didSet{
            guard let type = type else { return  }
            if type == 1{
                editBtn.isHidden = true
                deleteBtn.setTitle("申请", for: .normal)
            }else{
                
            }
        }
    }
    
    var model : YDOAStockModel!{
        didSet{
            guard let model = model else { return  }
            
            amountLb.text = "金额:\(model.zong ?? "")/元"
            priceLb.text = "价格:\(model.unit ?? "")/元"
            remainLb.text = "剩余数量:\(model.number ?? "")/\(model.com ?? "")"
            
            guiGeLb.text = "规格:\(model.content ?? "")"
            goosNameLb.text = "金额:\(model.name ?? "")"
            if model.x_type == "1"{
                goodsTypeLb.text = "类型: 办公用品"
            }else if  model.x_type == "2"{
                goodsTypeLb.text = "类型: 劳保用品"
            }else{
                  goodsTypeLb.text = "类型: 招待用品"
            }
            
            
        }
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
       
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    //type 1 删除
    @IBAction func deleteBtnClick(_ sender: Any) {
        if isApply == true {
            self.callback!(index,2)
        }else{
            self.callback!(index,1)
        }
       
    }
    //type  2  修改
    @IBAction func changeInfoClick(_ sender: Any) {
        self.callback!(index,2)
    }
    
}
